<?php
		ini_set('max_execution_time', 600);
		require_once("process2.php");
		$obj_process = new process();
		
		// Get link topic vay dam
		$url = "http://www.123mua.vn/u204/vay-dam.html";
		$str_content = $obj_process->get_content($url);
		$total = $obj_process->get_mid($str_content,">Trang 1/","</",0,0);
		$content = "";
		
		for($i = 1; $i <= $total; $i++){
			$url = "http://www.123mua.vn/u204/vay-dam.html?page=" . $i;
			$str_content = $obj_process->get_content($url);
			$str = $obj_process->get_mid($str_content, 'id="listing-product"', 'pager-row', 0, 0);
			$content .= $str;
		}
		$str = $obj_process->get_mid_to_array($content,'<a href="/','=rp',0,1);
		$str = array_unique($str);
		
		//remove element array by value  
		//if(($key = array_search($del_val, $messages)) !== false) {
			//unset($messages[$key]);
		//}
		
		//ghi file json
		$fp = fopen('results.json', 'w');
		fwrite($fp, json_encode($str));
		fclose($fp);